/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package py.una.pol.ii.is2.controller;

import com.sun.rave.web.ui.appbase.AbstractSessionBean;
import com.sun.webui.jsf.component.Accordion;
import java.util.Hashtable;
import java.util.List;
import javax.faces.FacesException;
import py.una.pol.ii.is2.domain.flota.Caracteristica;
import py.una.pol.ii.is2.domain.flota.DetallePlantillaMantenimiento;
import py.una.pol.ii.is2.domain.flota.Insumo;
import py.una.pol.ii.is2.domain.flota.Marca;
import py.una.pol.ii.is2.domain.flota.MarcaModelo;
import py.una.pol.ii.is2.domain.flota.Modelo;
import py.una.pol.ii.is2.domain.flota.PlantillaMantenimiento;
import py.una.pol.ii.is2.domain.flota.Tipo;
import py.una.pol.ii.is2.domain.flota.Vehiculo;
import py.una.pol.ii.is2.domain.registro.Chofer;
import py.una.pol.ii.is2.domain.registro.RegistroUtilizacion;
import py.una.pol.ii.is2.domain.sistema.Rol;
import py.una.pol.ii.is2.domain.sistema.Usuario;
import py.una.pol.ii.is2.domain.taller.DetalleOrdenMantenimientoInsumo;
import py.una.pol.ii.is2.domain.taller.DetalleOrdenMantenimientoPlantilla;
import py.una.pol.ii.is2.domain.taller.OrdenMantenimiento;
import py.una.pol.ii.is2.domain.flota.VehiculoCaracteristica;
import py.una.pol.ii.is2.domain.sistema.PantRol;

/**
 * <p>Session scope data bean for your application.  Create properties
 *  here to represent cached data that should be made available across
 *  multiple HTTP requests for an individual user.</p>
 *
 * <p>An instance of this class will be created for you automatically,
 * the first time your application evaluates a value binding expression
 * or method binding expression that references a managed bean using
 * this class.</p>
 *
 * @version SessionBean1.java
 * @version Created on 01/05/2009, 05:03:02 PM
 * @author markos
 */
public class SessionBean1 extends AbstractSessionBean {
    private static final long serialVersionUID = 8949428935620173861L;
    // <editor-fold defaultstate="collapsed" desc="Managed Component Definition">

    /**
     * <p>Automatically managed component initialization.  <strong>WARNING:</strong>
     * This method is automatically generated, so any user-specified code inserted
     * here is subject to being replaced.</p>
     */
    private void _init() throws Exception {
    }
    // </editor-fold>

    /**
     * <p>Construct a new session data bean instance.</p>
     */
    public SessionBean1() {
        accordionMenu = null;
    }

    /**
     * <p>This method is called when this bean is initially added to
     * session scope.  Typically, this occurs as a result of evaluating
     * a value binding or method binding expression, which utilizes the
     * managed bean facility to instantiate this bean and store it into
     * session scope.</p>
     * 
     * <p>You may customize this method to initialize and cache data values
     * or resources that are required for the lifetime of a particular
     * user session.</p>
     */
    @Override
    public void init() {
        // Perform initializations inherited from our superclass
        super.init();
        // Perform application initialization that must complete
        // *before* managed components are initialized
        // TODO - add your own initialiation code here

        // <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
        // Initialize automatically managed components
        // *Note* - this logic should NOT be modified
        try {
            _init();
        } catch (Exception e) {
            log("SessionBean1 Initialization Failure", e);
            throw e instanceof FacesException ? (FacesException) e : new FacesException(e);
        }

    // </editor-fold>
    // Perform application initialization that must complete
    // *after* managed components are initialized
    // TODO - add your own initialization code here
    }

    /**
     * <p>This method is called when the session containing it is about to be
     * passivated.  Typically, this occurs in a distributed servlet container
     * when the session is about to be transferred to a different
     * container instance, after which the <code>activate()</code> method
     * will be called to indicate that the transfer is complete.</p>
     * 
     * <p>You may customize this method to release references to session data
     * or resources that can not be serialized with the session itself.</p>
     */
    @Override
    public void passivate() {
    }

    /**
     * <p>This method is called when the session containing it was
     * reactivated.</p>
     * 
     * <p>You may customize this method to reacquire references to session
     * data or resources that could not be serialized with the
     * session itself.</p>
     */
    @Override
    public void activate() {
    }

    /**
     * <p>This method is called when this bean is removed from
     * session scope.  Typically, this occurs as a result of
     * the session timing out or being terminated by the application.</p>
     * 
     * <p>You may customize this method to clean up resources allocated
     * during the execution of the <code>init()</code> method, or
     * at any later time during the lifetime of the application.</p>
     */
    @Override
    public void destroy() {
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected ApplicationBean1 getApplicationBean1() {
        return (ApplicationBean1) getBean("ApplicationBean1");
    }
    

    public String logOut(){
        usuario = null;
        return "logout";
    }

    private Caracteristica caracteristica;
    private Usuario usuario;
    private Usuario usuarioEdit;
    private Chofer chofer;
    private Accordion accordionMenu;
    private Insumo insumo;
    private Marca marca;
    private Modelo modelo;
    private MarcaModelo marcaModelo;
    private Rol rol;
    private PlantillaMantenimiento plantillaMantenimiento;
    private DetallePlantillaMantenimiento detallePlantillaMantenimiento;
    private DetalleOrdenMantenimientoPlantilla detalleMantenimiento;
    private DetalleOrdenMantenimientoInsumo detalleOrdenMantenimientoInsumo;
    private List<DetallePlantillaMantenimiento> listaDetalleMantenimientos;
    private Tipo tipo;
    private Tipo tipoEdit;
    private Vehiculo vehiculo;
    private VehiculoCaracteristica vehiculoCaracteristica;
    private Boolean editingPlantilla;
    private Hashtable tablaPantallas;
    private RegistroUtilizacion registro;
    private List<PantRol> listaPantallaRol;


    public List<PantRol> getListaPantallaRol() {
        return listaPantallaRol;
    }

    public void setListaPantallaRol(List<PantRol> listaPantallaRol) {
        this.listaPantallaRol = listaPantallaRol;
    }

    public RegistroUtilizacion getRegistro() {
        return registro;
    }

    public void setRegistro(RegistroUtilizacion registro) {
        this.registro = registro;
    }
    

    public Hashtable getTablaPantallas() {
        return tablaPantallas;
    }

    public void setTablaPantallas(Hashtable tablaPantallas) {
        this.tablaPantallas = tablaPantallas;
    }

    /**
     *
     * Retorna el nivel de acceso que el usuario logeado tiene para
     * la pantalla nombrePantalla.
     *
     * @param nombrePantalla
     * @return
     */
    public Integer getNivelPermiso(String nombrePantalla) {
        Integer nivelPermiso = 0;
        try {
            nivelPermiso = (Integer) tablaPantallas.get(nombrePantalla);
        } catch (Exception e) {
            e.printStackTrace();
        }finally{
            return nivelPermiso;
        }
    }

    public DetalleOrdenMantenimientoInsumo getDetalleOrdenMantenimientoInsumo() {
        return detalleOrdenMantenimientoInsumo;
    }

    public void setDetalleOrdenMantenimientoInsumo(DetalleOrdenMantenimientoInsumo detalleOrdenMantenimientoInsumo) {
        this.detalleOrdenMantenimientoInsumo = detalleOrdenMantenimientoInsumo;
    }

    public DetallePlantillaMantenimiento getDetallePlantillaMantenimiento() {
        return detallePlantillaMantenimiento;
    }

    public void setDetallePlantillaMantenimiento(DetallePlantillaMantenimiento detallePlantillaMantenimiento) {
        this.detallePlantillaMantenimiento = detallePlantillaMantenimiento;
    }
    
    

    public Boolean getEditingPlantilla() {
        return editingPlantilla;
    }

    public void setEditingPlantilla(Boolean editingPlantilla) {
        this.editingPlantilla = editingPlantilla;
    }
    
    public List<DetallePlantillaMantenimiento> getListaDetalleMantenimientos() {
        return listaDetalleMantenimientos;
    }

    public void setListaDetalleMantenimientos(List<DetallePlantillaMantenimiento> listaDetalleMantenimientos) {
        this.listaDetalleMantenimientos = listaDetalleMantenimientos;
    }

    public Tipo getTipoEdit() {
        return tipoEdit;
    }

    public Vehiculo getVehiculo() {
        return vehiculo;
    }

    public void setVehiculo(Vehiculo vehiculo) {
        this.vehiculo = vehiculo;
    }

    public void setTipoEdit(Tipo tipoEdit) {
        this.tipoEdit = tipoEdit;
    }
    private OrdenMantenimiento ordenMantenimiento;

    public DetalleOrdenMantenimientoPlantilla getDetalleMantenimiento() {
        return detalleMantenimiento;
    }

    public void setDetalleMantenimiento(DetalleOrdenMantenimientoPlantilla detalleMantenimiento) {
        this.detalleMantenimiento = detalleMantenimiento;
    }

    public OrdenMantenimiento getOrdenMantenimiento() {
        return ordenMantenimiento;
    }

    public void setOrdenMantenimiento(OrdenMantenimiento ordenMantenimiento) {
        this.ordenMantenimiento = ordenMantenimiento;
    }

    public Tipo getTipo() {
        return tipo;
    }

    public void setTipo(Tipo tipo) {
        this.tipo = tipo;
    }

    public PlantillaMantenimiento getPlantillaMantenimiento() {
        return plantillaMantenimiento;
    }

    public void setPlantillaMantenimiento(PlantillaMantenimiento plantillaMantenimiento) {
        this.plantillaMantenimiento = plantillaMantenimiento;
    }

    public Rol getRol() {
        return rol;
    }

    public void setRol(Rol rol) {
        this.rol = rol;
    }

    public Usuario getUsuarioEdit() {
        return usuarioEdit;
    }

    public void setUsuarioEdit(Usuario usuarioEdit) {
        this.usuarioEdit = usuarioEdit;
    }

    public MarcaModelo getMarcaModelo() {
        return marcaModelo;
    }

    public void setMarcaModelo(MarcaModelo marcaModelo) {
        this.marcaModelo = marcaModelo;
    }

    public Modelo getModelo() {
        return modelo;
    }

    public void setModelo(Modelo modelo) {
        this.modelo = modelo;
    }

    public Marca getMarca() {
        return marca;
    }

    public void setMarca(Marca marca) {
        this.marca = marca;
    }

    public py.una.pol.ii.is2.domain.flota.Insumo getInsumo() {
        return insumo;
    }

    public void setInsumo(py.una.pol.ii.is2.domain.flota.Insumo insumo) {
        this.insumo = insumo;
    }

    public Accordion getAccordionMenu() {
        return accordionMenu;
    }

    public void setAccordionMenu(Accordion accordionMenu) {
        this.accordionMenu = accordionMenu;
    }

    public Chofer getChofer() {
        return chofer;
    }

    public void setChofer(Chofer chofer) {
        this.chofer = chofer;
    }

    public Usuario getUsuario() {
        return usuario;
    }

    public void setUsuario(Usuario usuario) {
        this.usuario = usuario;
    }

    public Caracteristica getCaracteristica() {
        return caracteristica;
    }

    public void setCaracteristica(Caracteristica caracteristica) {
        this.caracteristica = caracteristica;
    }
    
    public VehiculoCaracteristica getVehiculoCaracteristica() {
        return vehiculoCaracteristica;
    }

    public void setVehiculoCaracteristica(VehiculoCaracteristica vehiculoCaracteristica) {
        this.vehiculoCaracteristica = vehiculoCaracteristica;
    }
}
